package com.makemoney.miniprogram.modules.users.dao.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makemoney.miniprogram.modules.users.dao.IResourcesDao;
import com.makemoney.miniprogram.modules.users.entity.Resources;
import com.makemoney.miniprogram.modules.users.mapper.ResourcesMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ResourcesDaoImpl extends ServiceImpl<ResourcesMapper, Resources> implements IResourcesDao {
    @Override
    public List<Resources> listAll() {
        return list();
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean addList(List<Resources> entities) {
        return this.saveBatch(entities);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateList(List<Resources> entities) {
        return this.updateBatchById(entities);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean removeByIdList(List<Long> ids) {
        if (CollUtil.isEmpty(ids)) {
            return Boolean.TRUE;
        }
        return this.removeByIds(ids);
    }
}
